<%@ page contentType= "text/html;charset=gb2312" %>

<html>
<%@ include file="../common/base.jsp" %>

<script type="text/javascript" src="../styles/date/WdatePicker.js">
</script>

<body>

<script language="javascript">
function onSearch(){
	document.forms[0].action = "./query.o";
	document.forms[0].submit();
}

function onReset(){
	document.getElementById("step").value="all";
	document.getElementById("finalSn").value="";
	document.getElementById("internalSn").value="";
	document.getElementById("pn").value="";
	document.getElementById("keyword").value="";
	document.getElementById("operator").value="all";
	if(document.getElementById("beginDateStr"))
		document.getElementById("beginDateStr").value="";
	if(document.getElementById("endDateStr"))
		document.getElementById("endDateStr").value="";
}
</script>

<div id="container">
<%@ include file="../common/header.jsp" %>

	<div id="menu">
	     	<a href="<c:url value="/common/home.o"/>"><fmt:message key="Home" /></a> > <fmt:message key="Process" />
	        <div  style="float: right" ><fmt:message key="Logged" />: <c:out value="${currentUser.username}" /> (<a href="<c:url value="/common/logout.o"/>"><fmt:message key="Logout" /></a>)</div>
	</div>
	<div id="midbody">
	     	<div id="leftside">
		 		<br>
		   		<a href="<c:url value="/step/query.o"/>"><fmt:message key="AllProcess" /></a>
				<br><br>
				<a href="./query.o?archive=true"><fmt:message key="ArchiveProcess" /></a>
		   	</div>
			<div id="rightside">
					<div id="bigbox">
					    <div class="title clearfix">
					    	<div style="float: left"><fmt:message key="Process" /></div>
				    		<% if(request.getSession().getAttribute("searchCommandQuery") != null && ((SearchCommand)request.getSession().getAttribute("searchCommandQuery")).getArchive()){ %>
				    			- <fmt:message key="Archive" />
				    		<% } %>
					    	<%@ include file="../common/hidemenu.jsp" %>
					    </div>
					    <div class="content">
					        <form:form modelAttribute="searchCommand">
					            <form:errors path="*" element="div" cssClass="errors"/>
					            <div>
					            	<span><fmt:message key="Status" />:</span><form:select path="step" items="${statuses}"/>&nbsp;&nbsp;
					            	<span><fmt:message key="Operator" />:</span><form:select path="operator" items="${users}" itemValue="serial" itemLabel="serial"/>&nbsp;&nbsp;
					            	<span><fmt:message key="FinalSN" />:</span><form:input path="finalSn" size="10"/>&nbsp;&nbsp;
					            	<span><fmt:message key="InternalSN" />:</span><form:input path="internalSn" size="10"/>&nbsp;&nbsp;
					            	<span>PN:</span><form:input path="pn" size="10"/>&nbsp;&nbsp;
					            </div>
					            <div>
					            	<span><fmt:message key="From" />:</span>
				            		<input type="text" id="beginDateStr" name="beginDateStr" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate" style="width:100px" value="<fmt:formatDate  value="${searchCommand.beginDate}" pattern="yyyy-MM-dd"/>">&nbsp;&nbsp;
				            		<span><fmt:message key="To" />:</span>
					            	<input type="text" id="endDateStr" name="endDateStr" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate" style="width:100px" value="<fmt:formatDate  value="${searchCommand.endDate}" pattern="yyyy-MM-dd"/>">&nbsp;&nbsp;
					            	<span><fmt:message key="Keyword" />:</span><form:input path="keyword"/>&nbsp;&nbsp;
					            	<input type="button" value="<fmt:message key='Search' />" onclick="onSearch();">
					            	<input type="button" value="<fmt:message key='Reset' />" onclick="onReset();">
					            </div>
					        </form:form>
							
							<table id="processQuery">
								<tr>
									<th>
										<fmt:message key="ID" />
									</th>
									<th>
										<fmt:message key="Lot" />
									</th>
									<th>
										<fmt:message key="Process" />
									</th>
									<th width="10%">
										<fmt:message key="InnerSN" />
									</td>
									<th width="10%">
										<fmt:message key="FinalSN" />
									</td>
									<th width="10%">
										PN
									</td>
									<th>
										<fmt:message key="Step" />
									</td>
									<th>
										<fmt:message key="Actions" />
									</th>
								</tr>
								<% int i = 0; %>
								<c:forEach var="product" varStatus="status" items="${products}">
								<tr>
									<td>
										<c:out value="${product.id}" />
									</td>
									<td>
										<c:out value="${product.lot}" />
									</td>
									<td>
										<c:out value="${product.processId}" />
									</td>
									<td>
										<c:out value="${product.internalSn}" />
									</td>
									<td>
										<c:out value="${product.finalSn}" />
									</td>
									<td>
										<c:out value="${product.pn}" />
									</td>
									<td>
										<c:out value="${product.status}" />
									</td>
									<td>
										<a href="./view.o?productId=<c:out value='${product.id}' />">View</a>
									</td>
								</tr>
								</c:forEach>
							</table>
							<br>
							<% com.octopus.optiworks.controller.SearchCommand command = (com.octopus.optiworks.controller.SearchCommand)request.getAttribute("searchCommand"); %>
							<pg:pager url="querypage.o" items="<%= command.getTotal()%>" export="currentPageNumber=pageNumber" maxIndexPages="<%= command.getPageIndex()%>" maxPageItems="<%= command.getLength()%>">  
							    <pg:first>  
							        <a href="<c:out value="${pageUrl}" />">[<fmt:message key="First" />]</a>  
							    </pg:first>  
							    <pg:prev>  
							        <a href="<c:out value="${pageUrl}" />">[<fmt:message key="Previous" />]</a>  
							    </pg:prev>  
							    <pg:pages>  
							        <c:choose>  
							            <c:when test="${currentPageNumber eq pageNumber}">  
							                <font color="red">[<c:out value="${pageNumber}" />]</font>  
							            </c:when>  
							            <c:otherwise>  
							                <a href="<c:out value="${pageUrl}" />">[<c:out value="${pageNumber}" />]</a>  
							            </c:otherwise>  
							        </c:choose>  
							    </pg:pages>  
							    <pg:next>  
							        <a href="<c:out value="${pageUrl}" />">[<fmt:message key="Next" />]</a>  
							    </pg:next>  
							    <pg:last>  
							        <a href="<c:out value="${pageUrl}" />">[<fmt:message key="Last" />]</a>  
							        -
							        [<fmt:message key="Total" />:<%= command.getTotal()%>]
							    </pg:last>  
							</pg:pager>
						</div>
					</div>
			</div>
	</div>
	<%@ include file="../common/foot.jsp" %>
</div>
</body>
</html>
